<?
//(in_array($row[product_type],array('plan','domain','registerdomain','res_regdomain')) and strtotime("$row[purchase_expire_date] -14 days")-strtotime(date('Y-m-d'))<=0 and strtotime($row[purchase_expire_date])-strtotime(date('Y-m-d'))>=0)
//(is_numeric($row[client_blocked]) ? $bitmap['client_blocked'][($row[client_blocked])] : '-')
//	echo '<pre>';
//	print_r($data['res']);
//	echo '<pre>';

//	$master_db->query("SELECT store_id,title FROM stores WHERE reseller_id=$data[reseller_id]");
//	$store_title = $master_db->getNext();
	$store_title = array('title'=>$data['res'][result][0][store],'store_id'=>$data['res'][result][0][store_id]);

	$bitmap = array(
		'client_blocked'=>array(0=>'Active',1=>'Blocked',2=>'Paused',3=>'Expired',4=>'Active','expiring'=>'Expiring'),
		'currencies'=>array('USD'=>'US$','CAD'=>'CA$','AUD'=>'AU$','EUR'=>'&#8364','GBP'=>'&pound'),
		'order_status'=>array(0=>'Not Verified',128=>'Not Verified',256=>'Not Verified',512=>'Not Verified',16=>'OK',32=>'OK',2=>'Fraud',1=>'Refund',4=>'MBG',8=>'Charge-Back',64=>'Charge-Back',1024=>'Refund')
	);

	$curr_page = ($data['options']['offset'] ?  $data['options']['offset']/$data['options'][limit]+1 : 1);
	$pages = ceil($data['res']['num_rows']/$data['options']['limit']);
	$order_ids = array();

	$result_table = '<table width="100%"  border="0" cellspacing="0" cellpadding="0" class="master_tbl">
		</tr><tr><td height="2" colspan="9" bgcolor="#696969"></td></tr>
		<tr bgcolor="#DDE5E8">
		<td align="center" class="black"><strong>OrderID</strong></td>
		<td align="center" class="black"><strong>Date</strong><br/>mm/dd/yyyy</td>
		<td align="center" class="black"><strong>Username</strong></td>
		<td align="center" class="black"><strong>Type</strong></td>
		<td align="center" class="black"><strong>Item</strong></td>
		<td align="center">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
			  <tr>
				<td style="text-align:center;border-right:0px;" bgcolor="#C6D5DC" colspan="3" class="black"><strong>Transaction</strong></td>
			  </tr>
			  <tr bgcolor="#DDE5E8">
				<td width=80 style="text-align:center;border-bottom:0px;border-right:0px;" class="black"><strong>Total</strong></td>
				<td width=80 style="text-align:center;border-bottom:0px;border-right:0px;" class="black"><strong>Wholesale</strong></td>
				<td width=60 style="text-align:center;border-bottom:0px;border-right:0px;" class="black"><strong>Status</strong></td>
			  </tr>
			</table>
		</td>
		<td align="center" class="black"><strong>Account<br/>Status</strong></td>
		<td align="center" class="black"><strong>Net<br/>Profit</strong></td>
		<td align="center" class="black"><strong>Issued</strong><br/>mm/dd/yyyy</td>
		</tr><tr><td colspan="9" height="2" bgcolor="#696969"></td></tr>';

	foreach($data['res']['result'] as $k => $row){
		if($totals[($row[payment_currency_])]){
			$totals[($row[payment_currency_])]['amount_total'] = bcadd($totals[($row[payment_currency_])]['amount_total'],$row['amount_total'],2);
			$totals[($row[payment_currency_])]['amount_wholesale'] = bcadd($totals[($row[payment_currency_])]['amount_wholesale'],$row['amount_wholesale'],2);
			$totals[($row[payment_currency_])]['amount_reseller'] = bcadd($totals[($row[payment_currency_])]['amount_reseller'],$row['amount_reseller'],2);
			if(!in_array($row[order_id],$order_ids)){
				$totals[($row[payment_currency_])]['count'] += 1;
				$order_ids[] = $row[order_id];
			}
		}else{
			$totals[($row[payment_currency_])]['amount_total'] = $row['amount_total'];
			$totals[($row[payment_currency_])]['amount_wholesale'] = $row['amount_wholesale'];
			$totals[($row[payment_currency_])]['amount_reseller'] = $row['amount_reseller'];
			if(!in_array($row[order_id],$order_ids)){
				$totals[($row[payment_currency_])]['count'] = 1;
				$order_ids[] = $row[order_id];
			}
		}

		if(in_array($row['order_status'],array(1,2,4,1024))){
			$style = 'bgcolor=#FDC7F9';
			if($row['sale_type']=='reversal'){
				$style = 'bgcolor=#A15C9C';
			}
		}elseif(in_array($row['order_status'],array(8,64))){
			$style = 'bgcolor=#FECA50';
		}else{
			if(in_array($row['client_blocked'],array(1,3))){
				$style = 'bgcolor=#9EDAFC';
			}else{
				if($flag){
	                                if($tmp_order_id != $row[order_id]){
        	                                $tmp_order_id = $row[order_id];
						unset($flag);
						$style = 'bgcolor=#EBEBEB';
					}
				}else{
	                                if($tmp_order_id != $row[order_id]){
        	                                $tmp_order_id = $row[order_id];
						$flag = 1;
						$style = 'bgcolor=#FFFFFF';
					}
				}
			}
		}

		$result_table .= "<tr $style>
		<td style='padding-left:5px;' ".($style == 'bgcolor=#A15C9C' ?  "class='white-normal'" : "")." class='orange2'>$row[order_id]</td>
		<td height='16' ".($style == 'bgcolor=#A15C9C' ?  "class='white-normal'" : "")." class='black' align='center'>".date('m/d/Y',strtotime($row[order_date]))."</td>
		<td style='padding-left:10px;' ".($style == 'bgcolor=#A15C9C' ?  "class='orange'" : "")." class='orange2'>".($row[username] ? $row[username] : '-')."</td>
		<td align='center' ".($style == 'bgcolor=#A15C9C' ?  "class='white-normal'" : "")." class='black'>$row[sale_type]</td>
		<td align='center' ".($style == 'bgcolor=#A15C9C' ?  "class='white-normal'" : "")." class='black'>".($row[product_type] ? $row[product_type] : '-')."</td>
		<td>
			<table  width='100%' border='0' cellspacing='0' cellpadding='0'>
				<tr>
					<td width=75 align=right style='padding-right:5px;border-bottom:0px;border-right:0px;' ".($style == 'bgcolor=#A15C9C' ?  "class='white-normal'" : "")." class='black'>".($bitmap[currencies][($row[payment_currency_])])." $row[amount_total]</td>
					<td width=75 align=right style='padding-right:5px;border-bottom:0px;border-right:0px;' ".($style == 'bgcolor=#A15C9C' ?  "class='white-normal'" : "")." class='black'>".($bitmap[currencies][($row[payment_currency_])])." $row[amount_wholesale]</td>
					<td width=55 align=center style='padding-left:5px;border-bottom:0px;border-right:0px;' ".($style == 'bgcolor=#A15C9C' ?  "class='white-normal'" : "")." class='black'>".($row[sale_type]!='reversal' ? $bitmap['order_status'][($row[order_status])] : ($row[order_status]=='1024' ? 'P.Refund' : 'F.Refund'))."</td>
				</tr>
			</table>
		</td>
		<td align='center' ".($style == 'bgcolor=#A15C9C' ?  "class='white-normal'" : "")." class='black'>".(is_numeric($row[client_blocked]) ? ((in_array($row[product_type],array('plan','domain','registerdomain','res_regdomain')) and strtotime("$row[purchase_expire_date] -14 days")-strtotime(date('Y-m-d'))<=0 and strtotime($row[purchase_expire_date])-strtotime(date('Y-m-d'))>=0) ? $bitmap['client_blocked']['expiring'] : $bitmap['client_blocked'][($row[client_blocked])]) : '-')."</td>
		<td style='padding-right:5px;' align='right' ".($style == 'bgcolor=#A15C9C' ?  "class='white-normal'" : "")." class='black'>".$bitmap[currencies]['USD']." $row[amount_reseller]</td>
		<td align='center' ".($style == 'bgcolor=#A15C9C' ?  "class='white-normal'" : "")." class='black'>".($row[payed_reseller] ? date('m/d/Y',strtotime($row[payed_reseller])) : '-')."</td>
		</tr>";
	}

	$result_table .= "</tr><tr><td height='2' colspan='9' bgcolor='#696969'></td></tr>";

        foreach($totals as $currency=>$row){
                $result_table .= "<tr bgcolor='#0660B6'>
                        <td height=16 class='white' style='padding-left:10px;border-bottom:0px;border-right:0px;'>$row[count]</td>
                        <td colspan=4 class='white' style='border-bottom:0px;border-right:0px;'>SUB-TOTALS:</td>
                        <td style='border-bottom:0px;border-right:0px;'>
                                <table width='100%' border='0' cellspacing='0' cellpadding='0'>
                                <tr>
                                        <td width='75' align=right style='padding-right:5px;border-bottom:0px;border-right:0px;' class='white'>".$bitmap[currencies][$currency]." ".number_format($row[amount_total], 2, '.', ',')."</td>
                                        <td width='75' align=right style='padding-right:5px;border-bottom:0px;border-right:0px;' class='white'>".$bitmap[currencies][$currency]." ".number_format($row[amount_wholesale], 2, '.', ',')."</td>
                                        <td width='60' style='border-bottom:0px;border-right:0px;' class='white'></td>
                                </tr>
                                </table>
                        </td>
                        <td style='border-bottom:0px;border-right:0px;' class='white'></td>
                        <td align=right style='padding-right:5px;border-bottom:0px;border-right:0px;' class='white'>".$bitmap[currencies][USD]." ".number_format($row[amount_reseller], 2, '.', ',')."</td>
                        <td style='border-bottom:0px;' class='white'></td>
                </tr><tr><td height='1' colspan='9' bgcolor='#EBEBEB'></td></tr>";
        }

	$result_table .= "</tr><tr><td height='2' colspan='9' bgcolor='#696969'></td></tr>";
	$result_table .= '</table>';

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Statistics: General</title>
<link href="sales/styles.css" rel="stylesheet" type="text/css">
<script language="javascript" src="sales/tooltip.js"></script>
<script>
function page(val){
	var offset = <? echo($data['options']['offset'] ? $data['options']['offset'] : 0);?>;
	var limit = <?echo($data['options']['limit'] ? $data['options']['limit'] : 0);?>;
	var rows = <?echo($data['res']['num_rows'] ? $data['res']['num_rows'] : 0);?>;
	var page_num = document.daForm.elements['goto_page'].value;

	if(val=='prev'){
		if(offset!=0){
			document.daForm.elements['options[offset]'].value = offset-limit;
			document.daForm.submit();
		}
	}
	if(val=='next'){
		if(offset+limit<rows){
			document.daForm.elements['options[offset]'].value = offset+limit;
			document.daForm.submit();
		}
	}

	if(val=='goto_page'){
		if(valid_page_num(page_num)){
			document.daForm.elements['options[offset]'].value = limit * (page_num-1);
			document.daForm.submit();
		}else{
			alert('Invalid Page Number');
		}
	}
}

function valid_page_num(page_num){
	var pages = <?echo $pages;?>;
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;

	for (i = 0; i < page_num.length && IsNumber == true; i++) {
		Char = page_num.charAt(i);
		if (ValidChars.indexOf(Char) == -1) {
			IsNumber = false;
		}
	}
	if(IsNumber && page_num>=1 && page_num<=pages){
		return true;
	}else{
		return false;
	}
}
</script>
</head>

<body>
<form action="" method=POST name="daForm">
<table width="879" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<!-- GENERAL STATISTICS HEAD -->
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="16"><img src="sales/images/general_stats_icon.jpg" border="0"/></td>
    <td width="690" class="bluetext" valign="bottom" style="padding-bottom:3px; ">GENERAL STATISTICS</td>
    <td align="right"><a href="#" onClick="window.open('sales/help_popup_stats.html#general','','height=600,width=800,scrollbars=yes');return false;"><img src="sales/images/help.gif" alt="Online Help" border="0"></a><!--<a href="#"><img src="sales/images/v_tutorials.gif" alt="Video Tutorials" border="0"></a> <a href="#"><img src="sales/images/faq.gif" alt="Frequently Asked Questions" border="0"></a>--></td>
  </tr>
  <tr>
    <td height="5" colspan="3"></td>
  </tr>
</table>
<!-- GENERAL STATISTICS BODY -->
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="200" valign="top">
	   <!-- TRANSACTIONS TABLE -->
	   <table width="200" cellspacing="0" class="stats_tables">
		  <tr>
			<td height="17" width="90" bgcolor="#3FB157" class="white" align="center">Transactions</td>
			<td bgcolor="#218836" align="center" class="white">Amount</td>
		  </tr>
			<?
			if($data[res1][all][result]){
				foreach($data[res1][all][result] as $k=>$row){
					if($k%2!=0){
						$bgcolor = "bgcolor='#EBEBEC'";
					}else{
						unset($bgcolor);
					}
					echo "<tr $bgcolor>
						<td height='17' width='90' class='black' align='center'>$row[count]</td>
						<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies'][($row[payment_currency_])]." <strong>".number_format($row[amount_total], 2, '.', ',')."</strong></td>
					  </tr>";
				}
			}else{
				echo "
				  <tr>
					<td height='17' width='90' class='black' align='center'>0</td>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['USD']." <strong>0.00</strong></td>
				  </tr>
				  <tr bgcolor='#EBEBEC'>
					<td height='17' width='90' class='black' align='center'>0</td>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['EUR']." <strong>0.00</strong></td>
				  </tr>
				  <tr>
					<td height='17' width='90' class='black' align='center'>0</td>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['GBP']." <strong>0.00</strong></td>
				  </tr>
				  <tr bgcolor='#EBEBEC'>
					<td height='17' width='90' class='black' align='center'>0</td>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['CAD']." <strong>0.00</strong></td>
				  </tr>
				  <tr>
					<td height='17' width='90' class='black' align='center'>0</td>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['AUD']." <strong>0.00</strong></td>
				  </tr>";
			}
			?>
		</table>
	<!-- END TRANSACTIONS TABLE -->

	</td>
    <td width="17"  valign="top">&nbsp;</td>
    <td width="200"  valign="top">

	<!-- REFUND TABLE -->
	<table width="200" cellspacing="0" class="stats_tables">
		<tr>
		<td height="17" width="90" bgcolor="#B356AF" class="white" align="center">Refunds</td>
		<td bgcolor="#8E388A" align="center" class="white">Amount</td>
		</tr>
		<?
		if($data[res1][ref][result]){
			foreach($data[res1][ref][result] as $k=>$row){
				if($k%2!=0){
					$bgcolor = "bgcolor='#EBEBEC'";
				}else{
					unset($bgcolor);
				}
				echo "<tr $bgcolor>
					<td height='17' width='90' class='black' align='center'>$row[count]</td>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies'][($row[payment_currency_])]." <strong>".number_format($row[amount_total], 2, '.', ',')."</strong></td>
				  </tr>";
			}
		}else{
			if(!$data['res1']['all']['num_rows']){
			echo "
			  <tr>
				<td height='17' width='90' class='black' align='center'>0</td>
				<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['USD']." <strong>0.00</strong></td>
			  </tr>
			  <tr bgcolor='#EBEBEC'>
				<td height='17' width='90' class='black' align='center'>0</td>
				<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['EUR']." <strong>0.00</strong></td>
			  </tr>
			  <tr>
				<td height='17' width='90' class='black' align='center'>0</td>
				<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['GBP']." <strong>0.00</strong></td>
			  </tr>
			  <tr bgcolor='#EBEBEC'>
				<td height='17' width='90' class='black' align='center'>0</td>
				<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['CAD']." <strong>0.00</strong></td>
			  </tr>
			  <tr>
				<td height='17' width='90' class='black' align='center'>0</td>
				<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['AUD']." <strong>0.00</strong></td>
			  </tr>";
			  }else{
			  	foreach($data['res1']['all']['result'] as $k=>$row){
			  		echo "<tr>
                                		<td height='17' width='90' class='black' align='center'>0</td>
		                                <td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies'][($row[payment_currency_])]." <strong>0.00</strong></td>
                		          </tr>";
			  	}
			  }
		}
		?>
	</table></td>
		<!-- END REFUND TABLE -->

    <td width="17"  valign="top">&nbsp;</td>
    <td width="200"  valign="top">
	<!-- CHARGE-BACKS TABLE -->
	<table width="200" cellspacing="0" class="stats_tables">
		  <tr>
			<td height="17" width="90" bgcolor="#FECB50" class="white" align="center">Charge-Backs</td>
			<td bgcolor="#D69F1A" align="center" class="white">Amount</td>
		  </tr>
			<?
			if($data[res1][cb][result]){
				foreach($data[res1][cb][result] as $k=>$row){
					if($k%2!=0){
						$bgcolor = "bgcolor='#EBEBEC'";
					}else{
						unset($bgcolor);
					}
					echo "<tr $bgcolor>
						<td height='17' width='90' class='black' align='center'>$row[count]</td>
						<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies'][($row[payment_currency_])]." <strong>".number_format($row[amount_total], 2, '.', ',')."</strong></td>
					  </tr>";
				}
			}else{
				if(!$data['res1']['all'][num_rows]){
				echo "
				  <tr>
					<td height='17' width='90' class='black' align='center'>0</td>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['USD']." <strong>0.00</strong></td>
				  </tr>
				  <tr bgcolor='#EBEBEC'>
					<td height='17' width='90' class='black' align='center'>0</td>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['EUR']." <strong>0.00</strong></td>
				  </tr>
				  <tr>
					<td height='17' width='90' class='black' align='center'>0</td>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['GBP']." <strong>0.00</strong></td>
				  </tr>
				  <tr bgcolor='#EBEBEC'>
					<td height='17' width='90' class='black' align='center'>0</td>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['CAD']." <strong>0.00</strong></td>
				  </tr>
				  <tr>
					<td height='17' width='90' class='black' align='center'>0</td>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['AUD']." <strong>0.00</strong></td>
				  </tr>";
				}else{
                                	foreach($data['res1']['all']['result'] as $k=>$row){
                                        	echo "<tr>
                                                	<td height='17' width='90' class='black' align='center'>0</td>
	                                                <td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies'][($row[payment_currency_])]." <strong>0.00</strong></td>
        	                                  </tr>";
                	                }
				}
			}
			?>
		</table>
		<!-- END CHARGE-BACKS TABLE -->

	</td>
    <td width="20"  valign="top"></td>
    <td  valign="top" style="background:url(sales/images/dot.gif);width:2px;"></td>
    <td width="20"  valign="top"></td>
    <td valign="top">
	<!-- TOTAL TABLE -->
	<table width="100%" cellspacing="0" class="stats_tables">
		  <tr>
			<td height="17" bgcolor="#0660B6" class="white" align="center">NET REVENUE</td>
		  </tr>
			<?
			if($data[res1][ok][result]){
				foreach($data[res1][ok][result] as $k=>$row){
					if($k%2!=0){
						$bgcolor = "bgcolor='#EBEBEC'";
					}else{
						unset($bgcolor);
					}
					echo "<tr $bgcolor>
						<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies'][($row[payment_currency_])]." <strong>".number_format($row[amount_total], 2, '.', ',')."</strong></td>
					  </tr>";
				}
			}else{
				echo "
				  <tr>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['USD']." <strong>0.00</strong></td>
				  </tr>
				  <tr bgcolor='#EBEBEC'>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['EUR']." <strong>0.00</strong></td>
				  </tr>
				  <tr>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['GBP']." <strong>0.00</strong></td>
				  </tr>
				  <tr bgcolor='#EBEBEC'>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['CAD']." <strong>0.00</strong></td>
				  </tr>
				  <tr>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['AUD']." <strong>0.00</strong></td>
				  </tr>";
			}
			?>
		</table>
	<!-- END TOTAL TABLE -->

	</td>
	<td valign="top">
	<table width="100%" cellspacing="0" class="stats_tables">
		  <tr>
			<td height="17" bgcolor="#000082" class="white" align="center">NET PROFIT</td>
		  </tr>
			<?
			if($data[res1][ok][result]){
				foreach($data[res1][ok][result] as $k=>$row){
					if($k%2!=0){
						$bgcolor = "bgcolor='#EBEBEC'";
					}else{
						unset($bgcolor);
					}
					echo "<tr $bgcolor>
						<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['USD']." <strong>".number_format($row[amount_reseller], 2, '.', ',')."</strong></td>
					  </tr>";
				}
			}else{
				echo "
				  <tr>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['USD']." <strong>0.00</strong></td>
				  </tr>
				  <tr bgcolor='#EBEBEC'>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['USD']." <strong>0.00</strong></td>
				  </tr>
				  <tr>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['USD']." <strong>0.00</strong></td>
				  </tr>
				  <tr bgcolor='#EBEBEC'>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['USD']." <strong>0.00</strong></td>
				  </tr>
				  <tr>
					<td class='black' align='right' style='padding-right:5px; '>".$bitmap['currencies']['USD']." <strong>0.00</strong></td>
				  </tr>";
			}
			?>
		</table>
	</td>
  </tr>
  <tr>
    <td colspan="7" height="20"></td>
  </tr>
</table>

<!-- VIEW STATISTICS REPORT HEAD -->
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="16"><img src="sales/images/view_stats_report_icon.jpg" border="0"/></td>
    <td width="690" class="bluetext" valign="bottom" style="padding-bottom:3px; ">VIEW STATISTICS REPORT </td>
    <td align="right"><a href="#" onClick="window.open('sales/help_popup_stats.html#options','','height=600,width=800,scrollbars=yes');return false;"><img src="sales/images/help.gif" alt="Online Help" border="0"></a><!--<a href="#"><img src="sales/images/v_tutorials.gif" alt="Video Tutorials" border="0"></a> <a href="#"><img src="sales/images/faq.gif" alt="Frequently Asked Questions" border="0"></a>--></td>
  </tr>
  <tr>
    <td height="5" colspan="3"></td>
  </tr>
</table>

<!-- VIEW STATISTICS REPORT CONTENT -->
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
	<!-- Transaction Status -->
	<table width="223" border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<td colspan="2" class="black">Transaction Status:</td>
	  </tr>
	  <tr bgcolor="#F6D3B7">
		<td height="18" width="23"><input type="checkbox" name="params[order_status][1]" <?if($data['params']['order_status'][1]) echo 'checked';?>></td>
		<td width="151" bgcolor="#F6D3B7" class="black"><strong>ALL</strong></td>
	  </tr>
	  <tr bgcolor="#EBEBEC">
		<td height="18" width="23"><input type="checkbox" name="params[order_status][2]" <?if($data['params']['order_status'][2] and !$data['params']['order_status'][1]) echo 'checked';?> onClick="if(document.daForm.elements['params[order_status][1]'].checked==true && this.checked==true) document.daForm.elements['params[order_status][1]'].checked=false;"></td>
		<td class="black">OK</td>
	  </tr>
	  <tr bgcolor="#EBEBEC">
		<td height="18" width="23"><input type="checkbox" name="params[order_status][3]" <?if($data['params']['order_status'][3] and !$data['params']['order_status'][1]) echo 'checked';?> onClick="if(document.daForm.elements['params[order_status][1]'].checked==true && this.checked==true) document.daForm.elements['params[order_status][1]'].checked=false;"></td>
		<td class="black">REFUND</td>
	  </tr>
	  <tr bgcolor="#EBEBEC">
		<td height="18" width="23"><input type="checkbox" name="params[order_status][4]" <?if($data['params']['order_status'][4] and !$data['params']['order_status'][1]) echo 'checked';?> onClick="if(document.daForm.elements['params[order_status][1]'].checked==true && this.checked==true) document.daForm.elements['params[order_status][1]'].checked=false;"></td>
		<td class="black">CHARGE-BACK</td>
	  </tr>
	  <tr>
		<td height="18" width="23"></td>
		<td>&nbsp;</td>
	  </tr>
	</table>

	</td>
    <td width="60">&nbsp;</td>
    <td width="120">

	<!-- DATE SCRIPT -->

	<script src="sales/calendar.js"></script>
	<table width="120" border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<td colspan="2" class="black">Start Date Period:</td>
	  </tr>
	  <tr>
		<td width="102"><input id="sdate" name="sdate" <? if($data['sdate']) echo "value=$data[sdate]";?> title="Start date" class="black" style="width: 80px; height: 14px; border: 1px solid #89B4CC; font-weight:bold; color:#B51235; padding-left:9px;"></td>
		<td width="18" align="right"><a href="#" title="Click to choose start date" onclick="popUpCalendar(daForm, daForm.sdate, daForm.sdate, 'yyyy-mm-dd');"><img src="sales/images/calendar.gif" alt="Set Start Date" width="18" height="14" border="0"/></a></td>
	  </tr>
	  <tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	  </tr>
	  <tr>
		<td class="black" colspan="2">End Date Period:</td>
	  </tr>
	  <tr>
		<td><input id="edate" name="edate" <? if($data['edate']) echo "value=$data[edate]";?> title="End date" class="black" style="width: 80px; height: 14px; border: 1px solid #89B4CC; font-weight:bold; color:#B51235; padding-left:9px;"></td>
		<td align="right"><a href="#" title="Click to choose end date" onclick="popUpCalendar(daForm, daForm.edate, daForm.edate, 'yyyy-mm-dd');"><img src="sales/images/calendar.gif" alt="Set End Date" width="18" height="14" border="0"/></a></td>
	  </tr>
	  <tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	  </tr>
	</table>

	<!--  END DATE SCRIPT -->


	</td>
    <td width="60"></td>
    <td width="194">
	<!-- STORE LIST -->
	<table width="190px"  border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td colspan="2" class="black">Your Store Name:</td>
		  </tr>
		  <tr>
			<td>
				<select name="params[store_id]" class="silver2" style="width:100%; border:1px solid #7B9EBD;" size="7">
						<option selected value="" ><? echo $store_title['title']; ?></option>
				</select>
			</td>
		  </tr>
	</table>
	</td>
    <td>&nbsp;</td>
    <td width="198">

	<!-- CURRENCIES TABLE -->
	<table width="190px"  border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td colspan="2" class="black">Your currencies:</td>
		  </tr>
		  <tr>
			<td>
				<select name="params[payment_currency]" class="silver2" style="width:190px; border:1px solid #7B9EBD;" size="7">
						<option selected value="ALL" <?if(!$data[params][payment_currency]) echo 'selected';?>>ALL CURRENCIES (View All)</option>
						<option value="" >------------------------------------</option>
						<option value="USD" <?if($data[params][payment_currency]=='USD') echo 'selected';?>>USD (United States Dollar)</option>
						<option value="GBP" <?if($data[params][payment_currency]=='GBP') echo 'selected';?>>GBP (Great Britain Pound)</option>
						<option value="EUR" <?if($data[params][payment_currency]=='EUR') echo 'selected';?>>EUR (Euro)</option>
						<option value="CAD" <?if($data[params][payment_currency]=='CAD') echo 'selected';?>>CAD (Canadian Dollar)</option>
						<option value="AUD" <?if($data[params][payment_currency]=='AUD') echo 'selected';?>>AUD (Australian Dollar)</option>
<!--					<option value="BGL" >BGL (Bulgarian Lev)</option> -->
				</select>

			</td>
		  </tr>
		</table>
	<!-- END OF CURRENCIES TABLE -->

	</td>
  </tr>
  <tr>
    <td background="sales/images/horizontal_dots_stats.gif" height="18" colspan="7"></td>
  </tr>
  <tr>
    <td width="174" valign="middle" class="black">Results per page:
		<select class="blackdown" style="width:70px; height:16px;" name="options[limit]">
		<!--<option value="1000000">ALL</option>-->
		<option value="10" <?if($data['options']['limit']=='10') echo 'selected';?>>10</option>
		<option value="20" <?if($data['options']['limit']=='30') echo 'selected';?>>20</option>
		<option value="50" <?if($data['options']['limit']=='50') echo 'selected';?>>50</option>
		<option value="100" <?if($data['options']['limit']=='100') echo 'selected';?>>100</option>
		</select>
	</td>
    <td valign="middle">&nbsp;</td>
    <td>
    <input type=hidden name=options[offset]>
    <input style="width:102px; background-image:url(sales/images/view_stats_btn.jpg); border:0px; padding-left:12px;" type="submit" class="blackdown" value="View Report"></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="29" colspan="7"></td>
  </tr>
</table>
<!-- END VIEW STATISTICS REPORT CONTENT -->

<!-- SEARCH RESULTS TABLE -->
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	  <tr>
		<td width="9"><img src="sales/images/arrow_red.jpg" width="9" height="9"></td>
		<td style="padding-left: 5px;" class="black"><strong>Search Results from <? echo($data['options']['offset'] + 1);?> to <?echo(($data['options']['offset'] + $data['options']['limit'])>$data['res']['num_rows'] ? $data['res']['num_rows'] : ($data['options']['offset'] + $data['options']['limit']));?> for <span class="red"><? echo $store_title['title']; ?></span>:</strong>&nbsp;&nbsp;&nbsp; <span class="silver">[ from: </span><span class="red"><?echo ($data[sdate] ? date('M d, Y',strtotime($data['sdate'])) : date('M d, Y',strtotime($data['res']['result'][(count($data['res']['result'])-1)]['order_date'])));?></span><span class="silver"> to: </span><span class="red"><?echo ($data[edate] ? date('M d, Y',strtotime($data[edate])) : date('M d, Y',strtotime($data['res']['result']['0']['order_date'])));?></span><span class="silver"> ]</span></td>
		<td class="black" style="padding-left: 5px;padding-bottom:3px;" align="right"><a href="#" onClick="window.open('sales/help_popup_stats.html#results','','height=600,width=800,scrollbars=yes');return false;"><img src="sales/images/help.gif" alt="Online Help" border="0"></a><!--<a href="#"><img src="sales/images/v_tutorials.gif" alt="Video Tutorials" border="0"></a> <a href="#"><img src="sales/images/faq.gif" alt="Frequently Asked Questions" border="0"></a>--></td>
	  </tr>
</table>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td>
		<?
			if($data[res][num_rows]>0){
				echo $result_table;
			}else{
				$no_pages = 1;
				echo '<center><p class="black">No Results Found.<br>Please have in mind that these statistics cover only commission payments made after 05 October 2005 and pending commission payments.</p></center>';
			}
		?>
		</td>
	</tr>
</table>
<!-- END OF SEARCH RESULTS TABLE -->

<!-- PAGE NUMBERS AREA -->
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="11" colspan="14"></td>
  </tr>
  <tr>
	<?
	if($no_pages != 1){?>
    <td height="21" width="21"><?if($curr_page==1) echo '<img src="sales/images/result_arrow_disabled_left.jpg" alt="View Previous Results Page" width="21" height="21" border="0" />'; else echo '<a href="javascript:page(\'prev\');"> <img src="sales/images/result_arrow_enabled_left.jpg" alt="View Previous Results Page" width="21" height="21" border="0" /></a>';?></td>
    <td width="180" class="black" style="padding-left:7px; ">Results page: <span class="red style2"><strong><? echo $curr_page; ?></strong></span> of <span class="black style2"><strong><? echo $pages; ?></strong></span></td>
    <td width="21"><?if($curr_page==$pages) echo '<img src="sales/images/result_arrow_disabled_right.jpg" alt="View Next Results Page" border="0" />'; else echo '<a href="javascript:page(\'next\');"><img src="sales/images/result_arrow_enabled_right.jpg" alt="View Next Results Page" border="0" /></a>'; ?></td>
    <td width="23"></td>
    <td class="black" width="142" align="right" style="padding-right:7px; ">Go Directly to page: </td>
    <td width="40" align="left"><input name="goto_page" class="black" style="width:34px; height: 14px; padding-left:7px; border: 1px solid #89B4CC; font-weight:bold; color:#FD3E56;"></td>
    <td width="28" style="padding-left:7px; "><a href="javascript:page('goto_page');" ><img src="sales/images/go2page_arrow.jpg" alt="View Selected Page" border="0"></a></td>
	<?}else{ echo '<td width=455></td>'; }?>
    <td width="120"></td>
    <td width="21"><img src="sales/images/charge-back_lgnd.jpg" border="0"></td>
    <td width="95" class="black" style="padding-left:5px; ">Charge-Back</td>
    <td width="21"><img src="sales/images/refund_lgnd.jpg" border="0"></td>
    <td width="95" class="black" style="padding-left:5px; ">Refund</td>
    <td width="21"><img src="sales/images/blocked_lgnd.jpg" border="0"></td>
    <td width="95" class="black" style="padding-left:5px; ">Blocked</td>
  </tr>
  <tr>
    <td colspan="14" height="42"></td>
  </tr>
</table>
<!-- END OF PAGE NUMBERS AREA -->


<!-- LEGEND AREA -->
<!--
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="21"><img src="sales/images/legend_info.jpg" alt="Legend"></td>
    <td colspan="2" class="bluetext">LEGEND:</td>
  </tr>
  <tr>
    <td colspan="14" height="14"></td>
  </tr>
  <tr>

    <td height="25"></td>
    <td width="30"><span class="black"><img src="sales/images/help.gif" alt="Online Help" border="0"></span></td>
    <td width="830" class="black">&nbsp&nbsp&nbsp&nbsp Online Help</td>
  </tr>
  <tr>
    <td height="25"></td>
    <td><span class="black"><img src="sales/images/v_tutorials.gif" alt="Video Tutorials" border="0"></span></td>
    <td class="black">Video Tutorials </td>
  </tr>
  <tr>
    <td height="25">&nbsp;</td>
    <td><span class="black"><img src="sales/images/faq.gif" alt="Frequently Asked Questions"border="0"></span></td>
    <td class="black">Frequently Asked Questions (FAQ) </td>
  </tr>
  <tr>
    <td height="56" colspan="3"></td>
  </tr>
</table>
-->
<!-- END OF LEGEND AREA -->
</td></tr></table>
</form>
</body>
</html>
